package com.android.commcount.manager;

import android.content.ContentValues;

import com.android.commcount.bean.CommCount_Type;
import com.android.commcount.bean.Count_DetailInfo;

import org.litepal.LitePal;

import java.util.List;

public class SqlHelper {

    //获取所有历史记录，根据时间排序
    public static List<Count_DetailInfo> getHistoryByEditTime(long editTime) {
        List<Count_DetailInfo> countDetailInfos = LitePal.where("editTime = " + editTime).find(Count_DetailInfo.class);
        return countDetailInfos;
    }

    //将历史记录所有的选择状态重置
    public static void resetHistorySelectState() {
        try {
            ContentValues values = new ContentValues();
            values.put("isSelect", "0");
            LitePal.getDatabase().update("Count_DetailInfo", values, " isSelect=?", new String[]{"1"});
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //将历史记录所有的选择状态重置
    public static void resetFormSelectState() {
        try {
            ContentValues values = new ContentValues();
            values.put("isSelect", "0");
            LitePal.getDatabase().update("Count_FormRecord", values, " isSelect=?", new String[]{"1"});
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //获取所有历史记录，根据时间排序
    public static List<Count_DetailInfo> getHistory() {
        List<Count_DetailInfo> countDetailInfos = LitePal.order("editTime desc").find(Count_DetailInfo.class);
        return countDetailInfos;
    }
}
